package com.bazaaroid.server.gae.api.resources.client;

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;

import com.bazaaroid.server.gae.core.dao.client.ClientDAO;
import com.bazaaroid.server.gae.core.dto.client.ClientDTO;
import com.bazaaroid.server.gae.core.ioc.GuiceFactory;
import com.bazaaroid.server.gae.core.persistence.model.client.Client;
import com.google.appengine.api.datastore.KeyFactory;

@Path("/client/")
public class ClientResource {

	@GET
	@Produces({"application/xml", "application/json"})
	@Path("/{id}")
	public ClientDTO getById(@PathParam ("id") Long id) {
		ClientDAO clientDAO = GuiceFactory.getInjector().getInstance(ClientDAO.class);
		Client client = clientDAO.getById(KeyFactory.createKey(
				Client.class.getSimpleName(), id));
		return new ClientDTO(client);
	}

}
